home *** CD-ROM | disk | FTP | other *** search
- library Test1;
-
- uses
- SysUtils, Classes, Windows, Isapi;
-
- const
- HSE_IO_SYNC = 1;
- HSE_IO_ASYNC = 2;
-
- function GetExtensionVersion( Ver: THSE_VERSION_INFO ): BOOL; stdcall;
- begin
- Ver.dwExtensionVersion := MakeLong(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
- StrLCopy(Ver.lpszExtensionDesc,
- 'Internet Server Application, Example #1',
- HSE_MAX_EXT_DLL_NAME_LEN);
- Result := True;
- end;
-
- function HttpExtensionProc( var ECB: TEXTENSION_CONTROL_BLOCK ): DWORD; stdcall;
-
- procedure UnpackURLString( S: PChar; List: TStringList );
- { Parses and decodes a URL-encoded string. Copies variable values into List. }
- var
- LabelStr, ValueStr: ShortString;
- begin
- LabelStr := '';
- ValueStr := '';
- while S^ <> #0 do
- begin
- case S^ of
- '+' : ValueStr := ValueStr + ' ';
- '%' : begin
- ValueStr := ValueStr + Chr(StrToInt('$' + (S + 1)^ + (S + 2)^));
- Inc(S, 2);
- end;
- '=' : if LabelStr = '' then begin
- LabelStr := ValueStr;
- ValueStr := '';
- end;
- '&' : begin
- List.Values[LabelStr] := ValueStr;
- ValueStr := '';
- LabelStr := '';
- end;
- else ValueStr := ValueStr + S^;
- end;
- Inc(S);
- end;
-
- if ValueStr <> '' then
- List.Values[LabelStr] := ValueStr;
- end;
-
- function ISAWriteLn(Msg: string): Boolean;
- { Encapsulate the WriteClient callback into something more manageable. }
- var
- NBytes: DWORD;
- Buffer: PChar;
- begin
- Buffer := StrAlloc(Length(Msg) + 3);
- try
- StrPCopy(Buffer, Msg);
- StrCat(Buffer, #13#10);
- nBytes := StrLen(Buffer);
- Result := ECB.WriteClient(ECB.ConnID, Buffer, NBytes, HSE_IO_SYNC);
- finally
- StrDispose(Buffer);
- end;
- end;
-
- var
- FormFields: TStringList;
- I: Integer;
- PostData: PChar;
- begin
- FormFields := TStringList.Create;
- try
- with ECB do
- begin
- if StrPas(lpszMethod) = 'GET' then
- UnpackURLString(lpszQueryString, FormFields)
- else begin
- if Assigned(ECB.lpbData) then begin
- PostData := StrAlloc(cbAvailable + 1);
- StrMove(PostData, ECB.lpbData, cbAvailable);
- UnpackURLString(PostData, FormFields);
- end;
- end;
-
- ISAWriteLn('<HTML><HEAD>');
- ISAWriteLn('<TITLE>ISAPI Response Page</TITLE>');
- ISAWriteLn('</HEAD><BODY>');
-
- ISAWriteLn('<PRE>Environment Control Block');
- ISAWriteLn('<BR>');
- ISAWriteLn('cbSize = ' + IntToStr(cbSize));
- ISAWriteLn('dwVersion = ' + IntToStr(dwVersion shr 16) + '.' +
- IntToStr(dwVersion and $FFFF));
- ISAWriteLn('ConnID = ' + IntToStr(ConnID));
- ISAWriteLn('dwHttpStatusCode = ' + IntToStr(dwHttpStatusCode));
- ISAWriteLn('lpszLogData = ' + lpszLogData);
- ISAWriteLn('lpszMethod = ' + StrPas(lpszMethod));
- ISAWriteLn('lpszQueryString = ' + StrPas(lpszQueryString));
- ISAWriteLn('lpszPathInfo = ' + StrPas(lpszPathInfo));
- ISAWriteLn('lpszPathTranslated = ' + StrPas(lpszPathTranslated));
- ISAWriteLn('cbTotalBytes = ' + IntToStr(cbTotalBytes));
- ISAWriteLn('cbAvailable = ' + IntToStr(cbAvailable));
- if not Assigned(lpbData) then
- ISAWriteLn('lpbData = nil')
- else
- ISAWriteLn('lpbData = ' + StrPas(PostData));
-
- ISAWriteLn('lpszContentType = ' + StrPas(lpszContentType));
-
- ISAWriteLn('');
- ISAWriteLn('Form Fields:');
- for I := 0 to FormFields.Count - 1 do
- ISAWriteLn(IntToStr(I) + ' ' + FormFields[I]);
-
- ISAWriteln('</PRE>');
- ISAWriteLn('</BODY></HTML>');
- end;
- finally
- FormFields.Free;
- StrDispose(PostData);
- Result := HSE_STATUS_SUCCESS;
- end;
- end;
-
- exports
- GetExtensionVersion,
- HttpExtensionProc;
-
- begin
- end.
-